package pica.core;

import java.io.*;
import java.util.Date;
import java.util.Vector;
import javax.microedition.rms.*;

// Referenced classes of package pica.core:
//            d, e, f

public final class b
{

    b(d d1)
    {
        l = 4;
        S = d1;
        T = new f((byte)1);
        U = new f((byte)2);
        V = new f((byte)6);
        W = new f((byte)7);
        X = new f((byte)3);
        Y = new f((byte)4);
        A = new Vector();
        Q = new Vector();
        R = new Vector();
        Z = new f((byte)8);
    }

    public final String a()
    {
        return k;
    }

    public final String b()
    {
        return a;
    }

    public final String c()
    {
        return b;
    }

    public final boolean d()
    {
        return g;
    }

    public final void a(boolean flag)
    {
        g = flag;
    }

    public final boolean e()
    {
        return f;
    }

    public final String f()
    {
        return a + "@" + "pica";
    }

    public final String g()
    {
        return B;
    }

    public final String h()
    {
        return D;
    }

    public final Vector i()
    {
        return Q;
    }

    public final Vector j()
    {
        return R;
    }

    public final Object[] k()
    {
        return (new Object[] {
            new Boolean(h), new Byte(j), new Byte(i)
        });
    }

    public final void b(boolean flag)
    {
        h = flag;
    }

    public final void c(boolean flag)
    {
        f = flag;
    }

    public final synchronized Object[] a(String s1)
    {
        return T.a(s1);
    }

    private synchronized Object[] j(String s1)
    {
        return V.a(s1);
    }

    public final f l()
    {
        return V;
    }

    public final f m()
    {
        return W;
    }

    public final synchronized Object[] b(String s1)
    {
        return X.a(s1);
    }

    public final f n()
    {
        return Y;
    }

    public final synchronized Object[] c(String s1)
    {
        return Y.b(s1);
    }

    public final f o()
    {
        return X;
    }

    public final Vector p()
    {
        return A;
    }

    public final f q()
    {
        return U;
    }

    public final Object[] r()
    {
        return (new Object[] {
            n, o, p, q, r, s, t, u, v, w, 
            x, new Byte(y)
        });
    }

    public final Object[] s()
    {
        return (new Object[] {
            F, G, H, I, J
        });
    }

    public final Object[] t()
    {
        return (new Object[] {
            K, L, M, N, O, P
        });
    }

    public final byte u()
    {
        return l;
    }

    final synchronized void d(String s1)
    {
        if(s1.equals("\u4E0A\u7EBF"))
        {
            l = 7;
            m = e.b;
            return;
        }
        if(s1.equals("\u5FD9\u788C"))
        {
            l = 6;
            m = "dnd";
            return;
        }
        if(s1.equals("\u9690\u8EAB"))
        {
            l = 100;
            m = "iv";
            return;
        }
        if(s1.equals("\u79BB\u5F00"))
        {
            l = 5;
            m = "away";
            return;
        }
        if(s1.equals("\u4E0B\u7EBF"))
        {
            l = 4;
            m = e.c;
        }
    }

    final synchronized void a(String s1, byte byte0, String s2, int i1, String s3, String s4, byte byte1)
    {
        Object aobj1[];
        if(s3 == null)
            s3 = "";
        s3.toLowerCase();
        if(s2 == null || s2.equals(""))
            s2 = s1.substring(0, s1.indexOf("@pica"));
        if(s4 == null || s4.equals(""))
            s4 = "\u6211\u7684\u597D\u53CB";
        Object aobj[] = a(s1);
        aobj1 = (new Object[] {
            new Byte((byte)2), s1, new Byte(byte0), null, s2, new Integer(i1), new Boolean(s3.equals("yes")), new Byte((byte)3)
        });
        if(aobj != null)
        {
            aobj1[5] = aobj[5];
            aobj1[6] = aobj[6];
            if(((Byte)aobj[2]).byteValue() != 2 && ((Byte)aobj[2]).byteValue() != 3)
                aobj1[2] = aobj[2];
            aobj1[7] = aobj[7];
        }
        e(s1);
	    try {
		    T.a(aobj1, s4, byte1);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void e(String s1)
    {
	    try {
		    T.a(s1, true);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void a(String s1, String s2, String s3, String s4, String s5, int i1, boolean flag)
    {
        Object aobj[] = {
            new Byte((byte)3), s1, s2, s3, s4, s5, new Integer(i1), new Boolean(flag)
        };
        Z.a(aobj, false);
    }

    final synchronized void a(String s1, String s2, String s3, String s4, String s5, String s6)
    {
        Object aobj[] = {
            new Byte((byte)3), s1, s2, s3, s4, s5, s6
        };
        Z.a(aobj, false);
    }

    final synchronized void a(String s1, byte byte0, int i1, byte byte1)
    {
        Object aobj[];
        Object aobj1[] = (Object[])(aobj = T.a(s1, true))[3];
        aobj[2] = new Byte(byte0);
        aobj[5] = new Integer(i1);
        aobj[7] = new Byte(byte1);
	    try {
		    T.a(aobj, (String)aobj1[1], ((Byte)aobj1[2]).byteValue());
	    } catch (Exception e1) {
		    e1.printStackTrace(); 
	    }
	    return;
    }

    final synchronized void a(String s1, String s2, String s3, String as[][], String s4, String s5, String s6)
    {
        Object aobj[] = {
            new Byte((byte)2), s1, new Byte((byte)0), null, s2, as, s4, s5, s6
        };
	    try {
		    V.a(aobj, s3, (byte)0);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void b(String s1, String s2, String s3, String as[][], String s4, String s5, String s6)
    {
        Object aobj[] = {
            new Byte((byte)2), s1, new Byte((byte)8), null, s2, as, s4, s5, s6
        };
	    try {
		    T.a(aobj, s3, (byte)0);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void a(String s1, String s2, String s3, String s4)
    {
        Object aobj[];
        Object aobj1[];
        aobj = (new Object[] {
            new Byte((byte)2), s1, new Byte((byte)2), null, s2, s4, new Byte(((byte)(s1.endsWith("game.pica") ? 2 : 1)))
        });
        aobj1 = X.a(s1);
        if(aobj1 != null)
	        try {
		        X.a(s1, true);
	        } catch (Exception e1) {
		        e1.printStackTrace();
	        }
	    try {
		    X.a(aobj, s3, (byte)1);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void a(String s1, String s2, String s3, int i1, String s4)
    {
        byte byte0 = 0;
        if(s4.equals("enter"))
            byte0 = 3;
        else
        if(s4.equals("leave"))
            byte0 = 2;
        else
        if(s4.equals("exit"))
            byte0 = 1;
        Object aobj[] = {
            new Byte((byte)3), s1, new Byte(byte0), s2, s3, new Integer(i1), s4
        };
        Object aobj1[];
        if((aobj1 = Y.b(s1)) != null)
            Y.a(((Object) (aobj1)));
        Y.a(aobj, true);
    }

    final synchronized void a(String s1, String s2, String s3, String s4, String s5)
    {
        Object aobj[];
        Object aobj1[];
        byte byte0 = 2;
        if(s5.equals("member"))
            byte0 = 2;
        else
        if(s5.equals("owner"))
            byte0 = 1;
        else
        if(s5.equals("pending"))
            byte0 = 3;
        aobj = (new Object[] {
            new Byte((byte)2), s1, new Byte(byte0), null, s2, s4, new Byte((byte)3)
        });
        aobj1 = X.a(s1);
        if(aobj1 != null)
	        try {
		        X.a(s1, true);
	        } catch (Exception e1) {
		        e1.printStackTrace();
	        }
	    try {
		    X.a(aobj, s3, (byte)2);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void f(String s1)
    {
	    try {
		    X.a(s1, true);
	    } catch (Exception e1) {
		    e1.printStackTrace();
	    }
	    return;
    }

    final synchronized void a(String s1, String s2, String s3, String s4, String s5, String s6, Date date, 
            String as[][], String s7, String s8, String s9, String s10, Vector vector)
    {
        s1 = s1.indexOf('/') != -1 ? s1.substring(0, s1.indexOf('/')) : s1;
        String s11 = null;
        Object aobj[];
        Object aobj1[];
        if(s8 != null)
            s11 = s8;
        else
        if((aobj = a(s1)) != null)
            s11 = (String)aobj[4];
        else
        if(s1.equals("freesms.pica"))
            s11 = "PICA\u77ED\u4FE1";
        else
        if(s1.indexOf("@") > 0)
        {
            if((aobj1 = j(s1)) != null)
                s11 = (String)aobj1[4];
            else
                s11 = s1.substring(0, s1.indexOf("@"));
        } else
        if(s1.endsWith("pica"))
            if(s1.endsWith("customerserv.pica"))
                s11 = "PICA\u5BA2\u670D";
            else
                s11 = "\u7CFB\u7EDF\u6D88\u606F";
        aobj = (new Object[] {
            new Byte((byte)3), new Integer(-1), s1, s11, s2, s3, s4, s5, s6, date != null ? date : new Date(), 
            new Byte((byte)0), as, s7, null, s9, s10, vector
        });
        if(s1.indexOf("cluster") != -1 || s1.indexOf("@game.pica") != -1)
        {
            Object aobj2[];
            if(s8 != null)
                aobj[3] = s8;
            else
            if((aobj2 = c(s1)) != null)
                aobj[3] = aobj2[3];
            else
            if(s1.indexOf("%") == -1)
                aobj[3] = "\u516C\u544A";
            else
                aobj[3] = s1.substring(0, s1.indexOf("%"));
            if(B != null && s1.indexOf(B) != -1)
            {
                if(s3 == null || s3.length() == 0)
                {
                    aobj[10] = new Byte((byte)1);
                    A.addElement(((Object) (aobj)));
                } else
                if(!s1.startsWith(a))
                    A.addElement(((Object) (aobj)));
                if(A.size() > 15)
                    A.removeElementAt(0);
            }
            if(!s1.startsWith(a))
            {
                S.a(44, ((Object) (aobj)));
                return;
            }
        } else
        {
            if(s1.equals("pica") || s1.endsWith("@pica") || s1.endsWith("@qq.pica") || s1.endsWith("@msn.pica") || s1.endsWith("@cluster.qq.pica"))
            {
                U.a(aobj, false);
                c(aobj);
                if(U.b() > 15)
                    a(U.a(0));
                if(s1.indexOf("@pica") > 0 && a(s1) == null)
                {
                    a(s1, (byte)2, s1.substring(0, s1.indexOf("@")), 0, "", "\u964C\u751F\u4EBA", (byte)3);
                    S.a(8, null);
                }
                S.a(43, ((Object) (aobj)));
                return;
            }
            if(j(s1) == null)
            {
                U.a(aobj, false);
                c(aobj);
                S.a(43, ((Object) (aobj)));
                return;
            }
            W.a(aobj, false);
            if(W.b() > 10)
                W.b(10);
        }
    }

    public static synchronized void a(String s1, int i1)
    {
        Object obj;
        obj = null;
        Object obj1 = null;
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        ((DataOutputStream) (obj = new DataOutputStream(bytearrayoutputstream))).writeInt(i1);
        a(s1, bytearrayoutputstream.toByteArray());
        ((DataOutputStream) (obj)).close();
        break MISSING_BLOCK_LABEL_54;
        Exception exception;
        exception;
        if(obj != null)
            ((DataOutputStream) (obj)).close();
        throw exception;
        return;
        JVM INSTR dup ;
        obj;
        printStackTrace();
    }

    public static synchronized int g(String s1)
    {
        Object obj;
        obj = null;
        Object obj1 = null;
        int i1;
        obj = new ByteArrayInputStream(k(s1));
        DataInputStream datainputstream;
        i1 = (datainputstream = new DataInputStream(((java.io.InputStream) (obj)))).readInt();
        ((ByteArrayInputStream) (obj)).close();
        return i1;
        Exception exception;
        exception;
        if(obj != null)
            ((ByteArrayInputStream) (obj)).close();
        throw exception;
        JVM INSTR dup ;
        obj;
        printStackTrace();
        return 0;
    }

    public static synchronized void a(String s1, String s2)
    {
        Object obj;
        obj = null;
        Object obj1 = null;
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        ((DataOutputStream) (obj = new DataOutputStream(bytearrayoutputstream))).writeUTF(s2);
        a(s1, bytearrayoutputstream.toByteArray());
        ((DataOutputStream) (obj)).close();
        break MISSING_BLOCK_LABEL_54;
        Exception exception;
        exception;
        if(obj != null)
            ((DataOutputStream) (obj)).close();
        throw exception;
        return;
        JVM INSTR dup ;
        obj;
        printStackTrace();
    }

    public static synchronized String h(String s1)
    {
        Object obj;
        obj = null;
        Object obj1 = null;
        String s2;
        obj = new ByteArrayInputStream(k(s1));
        DataInputStream datainputstream;
        s2 = (datainputstream = new DataInputStream(((java.io.InputStream) (obj)))).readUTF();
        ((ByteArrayInputStream) (obj)).close();
        return s2;
        Exception exception;
        exception;
        if(obj != null)
            ((ByteArrayInputStream) (obj)).close();
        throw exception;
        JVM INSTR dup ;
        obj;
        printStackTrace();
        return "";
    }

    private static synchronized void a(String s1, byte abyte0[])
    {
        Object obj = null;
        if(((RecordStore) (obj = RecordStore.openRecordStore(s1, true))).getNumRecords() == 0)
            ((RecordStore) (obj)).addRecord(abyte0, 0, abyte0.length);
        ((RecordStore) (obj)).setRecord(1, abyte0, 0, abyte0.length);
        if(obj != null)
            ((RecordStore) (obj)).closeRecordStore();
        break MISSING_BLOCK_LABEL_55;
        Exception exception;
        exception;
        if(obj != null)
            ((RecordStore) (obj)).closeRecordStore();
        throw exception;
        return;
        JVM INSTR dup ;
        obj;
        printStackTrace();
    }

    private static synchronized byte[] k(String s1)
    {
        byte abyte0[] = null;
        Object obj = null;
        if(((RecordStore) (obj = RecordStore.openRecordStore(s1, true))).getNumRecords() == 1)
            abyte0 = ((RecordStore) (obj)).getRecord(1);
        if(obj != null)
            ((RecordStore) (obj)).closeRecordStore();
          goto _L1
        Exception exception;
        exception;
        if(obj != null)
            ((RecordStore) (obj)).closeRecordStore();
        throw exception;
        JVM INSTR dup ;
        obj;
        printStackTrace();
_L1:
        return abyte0;
    }

    public static synchronized boolean i(String s1)
    {
        String as[];
        if((as = RecordStore.listRecordStores()) == null)
            return false;
        for(int i1 = 0; i1 < as.length; i1++)
            if(as[i1].equals(s1))
                return true;

        return false;
    }

    public final synchronized void a(Object aobj[])
    {
        U.a(((Object) (aobj)));
        a(((Integer)aobj[1]).intValue());
        if(((Byte)aobj[10]).byteValue() == 0)
            z--;
    }

    public final synchronized void b(Object aobj[])
    {
        W.a(((Object) (aobj)));
    }

    public final synchronized void v()
    {
        W.a();
    }

    public final synchronized void c(Object aobj[])
    {
        String s1;
        RecordStore recordstore;
        s1 = "Msg-" + a;
        recordstore = null;
        recordstore = RecordStore.openRecordStore(s1, true);
        if(((Byte)aobj[10]).byteValue() == 3)
        {
            recordstore.deleteRecord(((Integer)aobj[1]).intValue());
        } else
        {
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
            DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
            boolean flag = true;
            try
            {
                recordstore.getRecord(((Integer)aobj[1]).intValue());
            }
            catch(Exception _ex)
            {
                flag = false;
            }
            if(!flag)
                aobj[1] = new Integer(recordstore.getNextRecordID());
            dataoutputstream.writeUTF(aobj[2] != null ? (String)aobj[2] : "");
            dataoutputstream.writeUTF(aobj[3] != null ? (String)aobj[3] : "");
            dataoutputstream.writeUTF(aobj[4] != null ? (String)aobj[4] : "");
            dataoutputstream.writeUTF(aobj[5] != null ? (String)aobj[5] : "");
            dataoutputstream.writeUTF(aobj[6] != null ? (String)aobj[6] : "");
            dataoutputstream.writeUTF(aobj[7] != null ? (String)aobj[7] : "");
            dataoutputstream.writeUTF(aobj[8] != null ? (String)aobj[8] : "");
            dataoutputstream.writeLong(((Date)aobj[9]).getTime());
            dataoutputstream.writeByte(((Byte)aobj[10]).byteValue());
            dataoutputstream.writeUTF(aobj[14] != null ? (String)aobj[14] : "");
            dataoutputstream.writeUTF(aobj[15] != null ? (String)aobj[15] : "");
            if(aobj[16] != null)
            {
                Vector vector = (Vector)aobj[16];
                dataoutputstream.writeInt(vector.size());
                for(int i1 = 0; i1 < vector.size(); i1++)
                {
                    String as[] = (String[])vector.elementAt(i1);
                    dataoutputstream.writeUTF(as[0]);
                    dataoutputstream.writeUTF(as[1]);
                }

            } else
            {
                dataoutputstream.writeInt(0);
            }
            byte abyte0[] = bytearrayoutputstream.toByteArray();
            if(flag)
            {
                recordstore.setRecord(((Integer)aobj[1]).intValue(), abyte0, 0, abyte0.length);
                z--;
            } else
            {
                recordstore.addRecord(abyte0, 0, abyte0.length);
                if(((Byte)aobj[10]).byteValue() == 0)
                    z++;
            }
            dataoutputstream.close();
            bytearrayoutputstream.close();
        }
        recordstore.closeRecordStore();
        recordstore = null;
        return;
        JVM INSTR dup ;
        Exception exception;
        exception;
        printStackTrace();
        if(recordstore != null)
            try
            {
                recordstore.closeRecordStore();
                return;
            }
            catch(Exception _ex) { }
        return;
    }

    private synchronized void a(int i1)
    {
        String s1 = "Msg-" + a;
        RecordStore recordstore = null;
        try
        {
            (recordstore = RecordStore.openRecordStore(s1, true)).deleteRecord(i1);
            recordstore.closeRecordStore();
            return;
        }
        catch(Exception _ex) { }
        if(recordstore != null)
            try
            {
                recordstore.closeRecordStore();
                return;
            }
            catch(Exception _ex) { }
    }

    public final synchronized void w()
    {
        U.a();
        z = 0;
        String s1 = "Msg-" + a;
        try
        {
            RecordStore.deleteRecordStore(s1);
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    public final synchronized void x()
    {
        String s1;
        RecordStore recordstore;
        RecordEnumeration recordenumeration;
        s1 = "Msg-" + a;
        recordstore = null;
        recordenumeration = null;
        if((recordstore = RecordStore.openRecordStore(s1, false)) != null && recordstore.getNumRecords() > 0)
        {
            DataInputStream datainputstream;
            for(recordenumeration = recordstore.enumerateRecords(null, null, true); recordenumeration.hasNextElement(); datainputstream.close())
            {
                int i1 = recordenumeration.nextRecordId();
                byte abyte0[] = recordstore.getRecord(i1);
                String s2 = (datainputstream = new DataInputStream(new ByteArrayInputStream(abyte0))).readUTF();
                String s3 = datainputstream.readUTF();
                String s4 = datainputstream.readUTF();
                String s5 = datainputstream.readUTF();
                String s6 = datainputstream.readUTF();
                String s7 = datainputstream.readUTF();
                String s8 = datainputstream.readUTF();
                long l1 = datainputstream.readLong();
                byte byte0 = datainputstream.readByte();
                String s9 = datainputstream.readUTF();
                String s10 = datainputstream.readUTF();
                System.out.println("rid=" + i1);
                int j1 = datainputstream.readInt();
                Vector vector = null;
                if(j1 > 0)
                {
                    vector = new Vector();
                    for(int k1 = 0; k1 < j1; k1++)
                        vector.addElement(new String[] {
                            datainputstream.readUTF(), datainputstream.readUTF()
                        });

                }
                d(new Object[] {
                    new Byte((byte)3), new Integer(i1), s2, s3, s4, s5, s6, s7, s8, new Date(l1), 
                    new Byte(byte0), null, null, null, s9, s10, vector
                });
            }

            recordenumeration.destroy();
        }
        recordstore.closeRecordStore();
        return;
        JVM INSTR dup ;
        Exception exception;
        exception;
        printStackTrace();
        if(recordenumeration != null)
            recordenumeration.destroy();
        if(recordstore != null)
            try
            {
                recordstore.closeRecordStore();
            }
            catch(Exception _ex) { }
        try
        {
            RecordStore.deleteRecordStore(s1);
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    private void d(Object aobj[])
    {
        if(((Byte)aobj[10]).byteValue() == 0)
            z++;
        for(int i1 = 0; i1 < U.b(); i1++)
        {
            Object aobj1[];
            if(((Integer)(aobj1 = (Object[])U.a(i1))[1]).intValue() > ((Integer)aobj[1]).intValue())
            {
                U.a(aobj, i1);
                return;
            }
        }

        U.a(aobj, false);
    }

    public final f y()
    {
        return T;
    }

    public final f z()
    {
        return Z;
    }

    private d S;
    String a;
    String b;
    String c;
    String d;
    boolean e;
    boolean f;
    boolean g;
    boolean h;
    byte i;
    byte j;
    String k;
    byte l;
    String m;
    String n;
    String o;
    String p;
    String q;
    String r;
    String s;
    String t;
    String u;
    String v;
    String w;
    String x;
    byte y;
    private f T;
    private f U;
    public int z;
    private f V;
    private f W;
    private f X;
    private f Y;
    Vector A;
    String B;
    String C;
    String D;
    boolean E;
    String F;
    String G;
    String H;
    String I;
    String J;
    String K;
    String L;
    String M;
    String N;
    String O;
    String P;
    Vector Q;
    Vector R;
    private f Z;
}
